// pages/wuliuInfo/wuliuInfo.js
var util = require('../../utils/util')
var shipStatusDic = {'0' : '物流状态：在途中', '1': '物流状态：已揽收', '2': '物流状态：疑难', '3': '物流状态：已签收'}
Page({
  data:{
    order:{}
  },
  onLoad:function(options){
    let wuliuData = wx.getStorageSync('wuliuData')
    this.setData({order:wuliuData})
    wx.removeStorageSync('wuliuData')
    let that = this
    let order = this.data.order
    wx.showToast({ title: 'loading..', icon: 'loading', uration: 20000})
    util.request(`/c2mwebservice/api/v1/members/${getApp().globalData.mohuanUser.memberId }/logistics/${order.masterOrderNo}`, function(res) {
      wx.hideToast
      let returnData = res.returnData
      order.shipNo = returnData.shipNo
      order.shipStatus = shipStatusDic[returnData.shipStatus] || '物流状态：暂无物流信息'
      let wuliuInfo = JSON.parse(returnData.data)
      that.setData({order: order, wuliuInfo: wuliuInfo})
    }, function(res) {
      wx.hideToast
    })
    // this.structureData(order)
    // 页面初始化 options为页面跳转所带来的参数
  },
  onReady:function(){
    // 页面渲染完成
  },
  onShow:function(){
    // 页面显示
  },
  onHide:function(){
    // 页面隐藏
  },
  onUnload:function(){
    // 页面关闭
  }
})